﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace SMS.Magus
{
    public partial class frmMovebyArea : DevExpress.XtraEditors.XtraForm
    {
        private string opflag = "";
        public XtraUserControl ParentControl { get; set; }
        public frmMovebyArea(string op)
        {
            InitializeComponent();
            this.opflag = op;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            frmAutoTel autel = (frmAutoTel)this.ParentControl; 
            if ((textBox1.Text.Length < 6)||!autel.isnullorint(textBox1.Text))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("必须是6位数字！");
                textBox1.Focus();
                return;
            }
            if ((textBox2.Text.Length < 6) || !autel.isnullorint(textBox1.Text))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("必须是6位数字！");
                textBox2.Focus();
                return;
            }
            Int64 fromNo = Int64.Parse("1" + textBox1.Text + "0000");
            Int64 toNo = Int64.Parse("1" + textBox2.Text + "9999");
            Int64 curNo = new long();
            if (opflag.Equals("up"))
            {
                if (autel.lvObjectNo.Items.Count > 0)
                {
                    foreach (ListViewItem it in autel.lvObjectNo.Items)
                    {
                        curNo = Int64.Parse(it.Text);
                        if ((curNo >= fromNo) && (curNo <= toNo))
                        {   //从下移动到上方
                            autel.lvSourceNo.Items.Add(it.Text);
                            autel.lvObjectNo.Items.Remove(it);
                        }
                    }
                }
            }
            else
            {
                if (autel.lvSourceNo.Items.Count > 0)
                {
                    foreach (ListViewItem it in autel.lvSourceNo.Items)
                    {
                        curNo = Int64.Parse(it.Text);
                        if ((curNo >= fromNo) && (curNo <= toNo))
                        {   //从上移动到下方
                            autel.lvObjectNo.Items.Add(it.Text);
                            autel.lvSourceNo.Items.Remove(it);
                        }
                    }
                }
            }
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
